/*
 * extglobals.h
 *
 *  Created on: Mar 27, 2013
 *      Author: locpx
 */

#ifndef EXTGLOBALS_H_
#define EXTGLOBALS_H_

#include "defines.h"

extern char CMD_BUFF[MAX_CMD_BUFF];
extern unsigned int CMD_BUFF_COUNT;

// Identifier of next move:
extern const unsigned char TRUE;
extern const unsigned char FALSE;

// Identifier of next move:
extern const unsigned char WHITE_MOVE;
extern const unsigned char BLACK_MOVE;

extern BOARD board;

/*
	RANKS:
	   9 |       81   82   83   84   85   86   87   88    89    (MSB,
	   8 |       72   73   74   75   76   77   78   79    80    left)
	   7 |       63   64   65   66   67   68   69   70    71
	   6 |       54   55   56   57   58   59   60   51    62
	   5 |       45   46   47   48   49   50   51   52    53
	   4 |       36   37   38   39   40   41   42   43    44
	   3 |       27   28   29   30   31   32   33   34    35
	   2 |       18   19   20   21   22   23   24   25    26
	   1 |        9   10   11   12   13   14   15   16    17
	   0 | (LSB,  0    1    2    3    4    5    6    7    8
		 |  right)
		  ----------------------------------------------------
	 FILES:       a    b    c    d    e    f    g    h    i
*/

extern const unsigned int A0;
extern const unsigned int A1;
extern const unsigned int A2;
extern const unsigned int A3;
extern const unsigned int A4;
extern const unsigned int A5;
extern const unsigned int A6;
extern const unsigned int A7;
extern const unsigned int A8;
extern const unsigned int A9;

extern const unsigned int B0;
extern const unsigned int B1;
extern const unsigned int B2;
extern const unsigned int B3;
extern const unsigned int B4;
extern const unsigned int B5;
extern const unsigned int B6;
extern const unsigned int B7;
extern const unsigned int B8;
extern const unsigned int B9;

extern const unsigned int C0;
extern const unsigned int C1;
extern const unsigned int C2;
extern const unsigned int C3;
extern const unsigned int C4;
extern const unsigned int C5;
extern const unsigned int C6;
extern const unsigned int C7;
extern const unsigned int C8;
extern const unsigned int C9;

extern const unsigned int D0;
extern const unsigned int D1;
extern const unsigned int D2;
extern const unsigned int D3;
extern const unsigned int D4;
extern const unsigned int D5;
extern const unsigned int D6;
extern const unsigned int D7;
extern const unsigned int D8;
extern const unsigned int D9;

extern const unsigned int E0;
extern const unsigned int E1;
extern const unsigned int E2;
extern const unsigned int E3;
extern const unsigned int E4;
extern const unsigned int E5;
extern const unsigned int E6;
extern const unsigned int E7;
extern const unsigned int E8;
extern const unsigned int E9;

extern const unsigned int F0;
extern const unsigned int F1;
extern const unsigned int F2;
extern const unsigned int F3;
extern const unsigned int F4;
extern const unsigned int F5;
extern const unsigned int F6;
extern const unsigned int F7;
extern const unsigned int F8;
extern const unsigned int F9;

extern const unsigned int G0;
extern const unsigned int G1;
extern const unsigned int G2;
extern const unsigned int G3;
extern const unsigned int G4;
extern const unsigned int G5;
extern const unsigned int G6;
extern const unsigned int G7;
extern const unsigned int G8;
extern const unsigned int G9;

extern const unsigned int H0;
extern const unsigned int H1;
extern const unsigned int H2;
extern const unsigned int H3;
extern const unsigned int H4;
extern const unsigned int H5;
extern const unsigned int H6;
extern const unsigned int H7;
extern const unsigned int H8;
extern const unsigned int H9;

extern const unsigned int I0;
extern const unsigned int I1;
extern const unsigned int I2;
extern const unsigned int I3;
extern const unsigned int I4;
extern const unsigned int I5;
extern const unsigned int I6;
extern const unsigned int I7;
extern const unsigned int I8;
extern const unsigned int I9;

extern const char* SQUARENAME[90];

// white = 0xxx, black = 1xxx
extern const unsigned char EMPTY;
extern const unsigned char WHITE_PAWN;
extern const unsigned char WHITE_KING;
extern const unsigned char WHITE_ADVISOR;
extern const unsigned char WHITE_ELEPHANT;
extern const unsigned char WHITE_ROOK;
extern const unsigned char WHITE_CANNON;
extern const unsigned char WHITE_HORSE;
extern const unsigned char BLACK_PAWN;
extern const unsigned char BLACK_KING;
extern const unsigned char BLACK_ADVISOR;
extern const unsigned char BLACK_ELEPHANT;
extern const unsigned char BLACK_ROOK;
extern const unsigned char BLACK_CANNON;
extern const unsigned char BLACK_HORSE;

extern const char PIECENAMES[15];

// BITSET has only one bit set
extern U32 BITSET[30];

// BITBOARDSET has only one bit set
extern BITBOARD BITBOARDSET[90];

// BOARDINDEX is used to translate [file][rank] to [square]
extern unsigned int BOARDINDEX[9][10];

extern BOOL debugMode;

extern const unsigned int SQUARE_TO_BITBOARD_INDEX[90];
extern const unsigned int SQUARE_TO_BITSET_INDEX[90];

// FILES is used to translate [square] [file]
extern const unsigned int FILES[90];

// FILES is used to translate [square] [file]
extern const unsigned int RANKS[90];

extern const unsigned int INDEX32[32];

extern const unsigned int DEBRUIJN32;

// Attack tables:
extern BITBOARD HORSE_ATTACKS[90][4];
extern BITBOARD HORSE_OBSTRUCTS[90][4];
extern BITBOARD ELEPHANT_ATTACKS[90][4];
extern BITBOARD ELEPHANT_OBSTRUCTS[90][4];
extern BITBOARD ADVISOR_ATTACKS[90];
extern BITBOARD KING_ATTACKS[90];
extern BITBOARD WHITE_PAWN_ATTACKS[90];
extern BITBOARD BLACK_PAWN_ATTACKS[90];

extern BITBOARD ATTACKS_RIGHT[90];
extern BITBOARD ATTACKS_TOP[90];
extern BITBOARD ATTACKS_LEFT[90];
extern BITBOARD ATTACKS_BOTTOM[90];

extern const int PAWN_VALUE;
extern const int KING_VALUE;
extern const int ADVISOR_VALUE;
extern const int ELEPHANT_VALUE;
extern const int ROOK_VALUE;
extern const int CANNON_VALUE;
extern const int HORSE_VALUE;

// Search parameters start here:
extern const int LARGE_NUMBER;
extern const int CHECKMATESCORE;
extern MOVE NOMOVE;

// Default search depth
extern const int DEFAULT_SEARCH_DEPTH;

// This constant is used in notBitBoard(BITBOARD) function
// In binary: 0011 1111 1111 1111 1111 1111 1111 1111
// The first two bits are not used in BITBOARD struct
extern const U32 LAST_THIRTY_BIT_SET;

#endif /* EXTGLOBALS_H_ */
